export function getMainDomain(url) {
  const parsedUrl = new URL(url);
  const { hostname } = parsedUrl;
  const parts = hostname.split('.');

  if (parts.length > 2) {
    return parts.slice(-2).join('.'); // 返回二级域名和顶级域名
  }

  return hostname; // 直接返回主域名
}

const currentUrl = window.location.href;

export const domain = getMainDomain(currentUrl);
